package com.dearbinge.utils;


import com.alibaba.fastjson.JSONObject;
import com.dearbinge.utils.httpClient.ApiRequest;
import com.dearbinge.utils.httpClient.ApiResponse;

/**
 *
 * @author luohui
 *
 */
public class IdcardUtil {

	private static String key = "f00b2f5be29196efb618633e724264b9";

	/**
	 * 身份证是否合法
	 * @param idcard
	 * @param realname
	 * @return
	 */
	public static String query(String idcard , String realname) {
		String status ="0";
		try {
			ApiResponse api = new ApiRequest("http://op.juhe.cn/idcard/query?",ApiRequest.Verb.GET)
			.charset("UTF-8").
			params("key", key).
			params("idcard", idcard).
			params("realname", realname)
			.send();
			String result = new String(api.getContent(), "UTF-8");
			Object parse = JSONObject.parse(result);
			System.out.println(parse);
			status = "1";
		} catch (Exception e) {
			e.printStackTrace();
			status = "0";
		}
		return status;
	}

	/**
	 *
	 * @param idcard
	 * @param realname
	 * @return
	 * 请求示例：http://japi.juhe.cn/enterprise/ent3?key=&keyword=91110108MA005BCA25&name=天聚地合（苏州）数据股份有限公司&oper_name=张三
	 */
	public static String query() {
		String status ="0";
		try {
			ApiResponse api = new ApiRequest("http://japi.juhe.cn/enterprise/ent3?",ApiRequest.Verb.GET)
			.charset("UTF-8").
			params("key", "e3dd483cfd8c0a4000c1cfb0180830d7").
			params("keyword", "asdf").
			params("name", "asdf").
			params("oper_name", "asdf")
			.send();
			String result = new String(api.getContent(), "UTF-8");
			Object parse = JSONObject.parse(result);
			System.out.println(parse);
			status = "1";
		} catch (Exception e) {
			e.printStackTrace();
			status = "0";
		}
		return status;
	}

//	public static void main(String[] args) {
//		query("430521199005097551","罗辉");
//	}

}
